package com.study.sbsummary.utils;

import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class ThreadLocalContextHolder {

    private static final Logger LOGGER = LoggerFactory.getLogger(ThreadLocalContextHolder.class);

    private static final ThreadLocal<Map<String, Boolean>> context = new MyThreadLocal();

    private static class MyThreadLocal extends ThreadLocal<Map<String, Boolean>> {

        @Override
        protected Map<String, Boolean> initialValue() {
            return Maps.newHashMap();
        }
    }

    public static Boolean get(String key) {
        return context.get().get(key);
    }

    public static void put(String key, Boolean value) {
        context.get().put(key, value);
    }

    public static void reset() {
        context.get().clear();
    }

}
